/*
  返回数组以求数组的最值
 */

import java.util.Scanner;

public class MothodDemo06 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int arr[] = new int[6];
        //引导输入
        for (int i = 0; i < arr.length; i++) {
            System.out.println("请输入第" + (i+1) + "个数字:");
            arr[i] = sc.nextInt();
        }
        int[] maxAndMin=getMaxAndMin(arr);
        System.out.println("最大值为:" + maxAndMin[0]);
        System.out.println("最小值为:" + maxAndMin[1]);

    }

    public static int[] getMaxAndMin(int[] arr) {
        int max = arr[0];
        int min = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (max < arr[i]) {
                max = arr[i];
            }
            if (min > arr[i]) {
                min = arr[i];
            }
        }
        int getMaxAndMin[ ]={ max, min} ;

        return getMaxAndMin;

    }

}
